package edu.zut.cs.software.teach.Base.service.impl;

import java.io.Serializable;


import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;


import edu.zut.cs.software.teach.Base.dao.GenericDao;
import edu.zut.cs.software.teach.Base.domain.BaseEntity;
import edu.zut.cs.software.teach.Base.service.GenericManager;
/**
 * 
 * @author  汪云飞 yuki
 *
 * @param <PK>
 * @param <T>
 */
public  class GenericManagerImpl<PK extends Serializable, T extends BaseEntity<PK>> implements GenericManager<PK, T> {
//	}
	
	protected GenericDao<T, PK> dao;
	
	
	public T findById(PK smsId) {
		return this.dao.findById(smsId).get();
	}

	public void deleteAll() {
		this.dao.deleteAll();
		
	}
	public void deleteId(PK smsId) {
		this.dao.deleteById(smsId);
	}
	
	public Iterable<T> findAll() {
		return this.dao.findAll();
	}

	
	public Page<T> findAll(Pageable page) {
		Page<T> result = this.dao.findAll(page);
		return result;
	}

	
	public Iterable<T> save(Iterable<T> entities) {
		return this.dao.saveAll(entities);
	}

	
	public T save(T entity) {
		T data = this.dao.save(entity);
		return data;
	}

	
	public long count() {
		return this.dao.count();
	}

	

	
}
